﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Lawyer.Web.Ajax
{
    public partial class ajax_schedule : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindSchedule();
        }

        private void BindSchedule()
        {
            if (Session["UserID"] == null) {
                return;
            }
            string UserID = Session["UserID"].ToString();
            string strWhere = " LawyerID = '" + UserID + "'";
            Lawyer.BLL.ActivityInfo bll = new Lawyer.BLL.ActivityInfo();
            List<Lawyer.Model.ActivityInfo> list = bll.GetModelList(strWhere);
            string oneitem = "";
            string result = "";
            int index = 1;
            foreach (var item in list)
            {
                string id = index.ToString();//item.ActivityID;
                index++;
                string title = item.Title;
                string start = item.StartDate.Value.ToUniversalTime().ToString();
                string end = item.EndDate.Value.ToUniversalTime().ToString();
                oneitem += "{\"id\":" + id + ",\"title\":\"" + title + "\",\"start\":\"" + start + "\",\"end\":\"" + end + "\",\"allDay\":false},";
                //oneitem += "{id:" + id + ",title:\"" + title + "\",start:\"" + start + "\",end:\"" + end + "\",allDay:false},";
            }
            result = "[" + oneitem.Substring(0, oneitem.Length - 1) + "]";
            Response.Write(result);
        }
    }
}
